
JSON.form2param = function (form) {
    var objArray = form;
    var jsondata = {};
    for (var obj in objArray) {
        if (objArray[obj].value != '') {
            jsondata[objArray[obj].name] = objArray[obj].value;
        }
    }
    return jsondata;
}

function timeFormatter(value, row, index) {
    return new Date(value).Format("yyyy-MM-dd  hh:mm:ss");
}

function dateFormatter(value, row, index) {
    return new Date(value).Format("yyyy-MM-dd");
}

Date.prototype.Format = function (fmt) { //author: meizz
    var o = {
        "M+": this.getMonth() + 1,                 //月份
        "d+": this.getDate(),                    //日
        "h+": this.getHours(),                   //小时
        "m+": this.getMinutes(),                 //分
        "s+": this.getSeconds(),                 //秒
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度
        "S": this.getMilliseconds()             //毫秒
    };
    if (/(y+)/.test(fmt))
        fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt))
            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
}


function jobFormatter(value, row, index) {
    switch (value) {
        case 0:
            return "管理员";
        case 1:
            return "总经理";
        case 2:
            return "副总经理";
        case 3:
            return "行政人员";
        case 4:
            return "财政人员";
        case 5:
            return "部门经理";
        case 6:
            return "普通员工";
    }
    return "";
}

function sexFormatter(value, row, index) {
    switch (value) {
        case 1:
            return "男";
        case 2:
            return "女"
    }
    return "";
}

function stateFormatter(value, row, index) {
    switch (value) {
        case 0:
            return "未审批";
        case 1:
            return "部门经理已审批";
        case 2:
            return "副总经理已审批";
        case 3:
            return "总经理已审批";
        case 4:
            return "驳回";
        case 5:
            return "通过";
    }
    return "";
}

